import requests
import tqdm


def download(url, name):
    resp = requests.get(url, stream=True)
    total = int(resp.headers.get('content-length', 0))
    with open(name, 'wb') as file, tqdm(desc=name, total=total, unit='iB', unit_scale=True, unit_divisor=1024) as bar:
        for data in resp.iter_content(chunk_size=1024):
            size = file.write(data)
            bar.update(size)


if __name__ == '__main__':
    url = "https://dcsp-uat.oss-cn-shanghai.aliyuncs.com/AlgorithmData/old.tar.gz"
    download(url, "old.tar.gz")